#!/bin/bash
if [ -z $1 ]; then 
   echo 'using  sh ./onStart.sh dev'
   exit 1
fi

#停止容器
docker stop gjs-api-1
docker rm gjs-api-1
#s删除镜像
docker rmi $(docker images |grep "gjs-api"|awk '{print $3}')
#cp -r ../bin .
rm -rf  target
cp  -r ../target .

#docker build --force-rm  -t gjs/api  .
#docker run -ti --name gjs-api -p8080:8080 -idt gjs/api:latest
docker-compose build --build-arg PROFILE_ACTIVE="$1" --force-rm
if [ "$1" == "prod" ];then
    docker push registry.cn-hangzhou.aliyuncs.com/zhangyunh/zyh:gjs-api
else
  docker-compose up -d
  docker logs -f --tail=100 gjs-api-1
fi
